﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Blazing.BusinessObjects;
using System.BusinessObjects.With;
using Blazing.BusinessObjects.Queries;

namespace Blazing.WebFacade
{
    [System.ComponentModel.DataObject]
    public class SettingsController
    {
        #region DataObject Methods
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Delete, true)]
        public void DeleteSetting(Setting obj)
        {
            obj.Delete();
            obj.Save();
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public Setting NewSetting(Setting obj)
        {
            obj.Save();
            return obj;
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public Setting UpdateSetting(Setting obj)
        {
            Setting.Evict(obj.ID);
            obj.Save();
            return obj;
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public IList<Setting> GetSettings(int siteId)
        {
            return Setting.Search(QrySearchSettingsBySite.Query(siteId));
        }

        public Setting GetSetting(int siteId, string settingKey)
        {
            return Setting.Fetch(QrySearchSettingsBySite.Query(siteId, settingKey));
        }

        #endregion
    }
}
